<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<% String path=request.getContextPath(); String basePath=request.getScheme()+ "://" + request.getServerName() + ":" + request.getServerPort() + path+ "/"; %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" >
<html  xmlns="http://www.w3.org/1999/xhtml"> 
<head>
<base href="<%=basePath%>">
<title>产品配置</title>
	<%@ include file="/WEB-INF/jsp/common/common.jsp" %>
	<script src="<%=path%>/js/jquery.divbox.js" type="text/javascript"></script>
	<script type="text/javascript">
	$(document).ready(function() {
		queryDefinition(1);
	});
	function add(){
		window.location.href='<%=path%>/ruleConfiger/add';
	}
	//为查询投保方案 拼接参数
	function queryDefinition(pageIndex){
		var partnerNo = $.trim($('#partnerNo').val());
		var planNo = $.trim($('#planNo').val());
		var ruleName=$.trim($('#ruleName').val());
		loadDefinition({current:pageIndex,size:10,partnerNo:partnerNo,planNo:planNo,ruleName:ruleName});
	}
	//加载投保方案
	function loadDefinition(param){
		$.openLoading();
		$.ajax({
				url : "<%=path%>/ruleConfiger/queryDefinitionPage?"+new Date().getTime(),
				type : 'POST',
				async : true,
				dataType:'json',
				data:param,
				success : function(page) {
					$.closeLoading();
					if($.validate(page))return;
					
					var firstbutton ='';
					firstbutton ="<input class='input_fxk' name='radioChannelInfo' type='radio' value=''>"
					
					var lastbutton = "<a href='javascript:void(0)' onClick='editRuleDefin(this);return false'>编辑</a>&nbsp;<a href='javascript:void(0)' onClick='delRuleDefin(this);return false'>删除</a>";
					var tableContent = creatTable1("ID,RULE_NAME,CHANNEL_NAME,PLAN_NO,INSERT_TIME",page,firstbutton,lastbutton);
					
					var tableObj = $("#DefinitionTable");
					tableObj.find("tbody").remove();
					tableObj.append(tableContent);
					var strPage = creatChannelPage(param.current,6,page.maxPage,"94");
					var pageDIV = $("#DefinitionpageDIV");
					pageDIV[0].innerHTML="";
					pageDIV.append(strPage);
					
					bindradio();//点击单选按钮，该行高亮显示			
				}
			});
	}
	function bindradio(){
		$("input[name='radioChannelInfo']").click(function(){
			$("input[name='radioChannelInfo']").parent().parent().removeClass("table_highlighter");
			$(this).parent().parent().addClass("table_highlighter");
       	});
	}
	//点击“选择(合作伙伴)”
	function openChannelPageDiv(){
		queryChannelInfo(1);
	}
	//为查询合作伙伴 拼接参数
	function queryChannelInfo(pageIndex){
		var channelCode = $.trim($('#channelCode_choose').val());
		var channelName = $.trim($('#channelName_choose').val());
		
		loadChannelInfo({current:pageIndex,size:8,channelCode:channelCode,channelName:channelName});
	}
	//加载合作伙伴
	function loadChannelInfo(param){
		$.openLoading();
		$.ajax({
			url : "<%=path%>/nlifePlanConfig/queryChannelInfoPageByCriteria?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:param,
			dataType:'json',
			success:function(page){
				$.closeLoading();
				if($.validate(page))return;
	
				var radioObj ="<input class='input_fxk' name='radioChannelInfo' type='radio' value=''>";
				var fieldNames = "channelCode,channelName";
				var tableContent = creatTable1(fieldNames,page,radioObj);
				var tableObj = $("#channelInfoTable");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);
				
				var strPage = creatChannelPage2(param.current,6,page.maxPage,"42");
				var pageDIV = $("#channelInfoPageDIV");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);
				
				$('#channelInfoDiv').OpenDiv();
				
				bindradio();
			}
		});
	}  
	//点击“确定”按钮，选择合作伙伴
	function chooseChannelInfo(){
		var selected = $("input[name='radioChannelInfo']:checked");
		if(selected.length==0){
			$.message("error", "请选择一个合作伙伴");
			return;
		}
		var channelCode = selected.parent().parent().children(" td:eq(1)").html();
		$('#partnerNo').val(channelCode);
		
		closeChannelInfoDiv();
	}
	//关闭 选择合作伙伴 弹出层
	function closeChannelInfoDiv(){
		$("#channelInfoDiv").CloseDiv();	
		
		$('#channelCode_choose').val("");
		$('#channelName_choose').val("");
	}
	/**编辑*/
	function editRuleDefin(obj){
			var id=$(obj).parent().parent().children("td:eq(1)").html()	
			if(!id){
				$.message("error", "参数错误，请联系管理员");
				return;
			}
			window.location.href='<%=path%>/ruleConfiger/editRule?ruleId='+id;
	}
	/**删除*/
	function delRuleDefin(obj){
		$.dialog({
			type: "warn",//success,error
			content: "您确定要删除该规则吗？",
			onOk: function() {
				var id=$(obj).parent().parent().children("td:eq(1)").html()	
				if(!id){
					$.message("error", "参数错误，请联系管理员");
					return;
				}
				delRuleDefinition(id);
			}
		});
	}
	function delRuleDefinition(id){
		$.openLoading();
		$.ajax({
			url : "<%=path%>/ruleConfiger/deletRule?"+new Date().getTime(),
			type : 'POST',
			async : true,
			data:{ruleId:id},
			dataType:'json',
			success:function(data){
				$.closeLoading();
				$.message(data.result, data.message);
				if(data.result=='success'){
					queryDefinition(1);
				}
			}
		});
	}
	function vreset(){
		$('#partnerNo').val('');
		$('#ruleName').val('');
		$('#planNo').val('');
	}
	</script>
</head>
<body >
	<div class="current">
           <table class="current_table_1">
              <tbody>
                <tr class="f2">
                  <td>
                    <img src="./images/current_1.jpg">
                  </td>
                  <td class="current_table_1_td">
                    <img src="images/current_1.png">&nbsp;您现在的位置：&nbsp;
                      <span style=" color:#136bab; ">界面出单管理 
                      <span style="padding:0 5px; font-weight:bold; line-height:28px;">&gt;</span>录单界面订制
                  </span>
                  </td>
                  <td><img src="./images/current_3.jpg"></td>
              </tr>
           </tbody>
         </table>
      </div>
		
		<table class="table_02" id="table">
			<tr>
				<td>
					<table class="search_table">
						<tr height="30px">
							<td width="32%" height="30">
								<div style="display: inline-block;">
									合作伙伴代码：
									<input name="txt3"  id="partnerNo" value="" readonly="readonly" style="background: #ccc;" class="input_text">
									<input type="button"  class="input_button_1" id="openChannelPageDivBtn" value="选择" onClick="openChannelPageDiv()"/>
								</div>
							</td>
							<td width="20%" height="30">规则名称：
								<input name="txt3" id="ruleName" type="text" class="input_text" maxlength="100" value="">
							</td>
							<td width="20%" height="30">方案号：
								<input name="txt3" id="planNo" type="text" class="input_text" maxlength="100" value="">
							</td>
							<td style="text-align: center;" colspan="5" width="100%" height="30">
								<input type="button" class="input_button_1" id="searchBtn" value="查询" onClick="queryDefinition(1)" />&nbsp;
							    <input type="button" class="input_button_1" id="searchBtn" value="重置" onClick="vreset()" />
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table class="search_table">
						<tr height="30px">
							<td width="100%" height="30">
								<input type="button" class="input_button_1" id="searchBtn" value="新增" onClick="add()" />&nbsp;
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table id="DefinitionTable" class="content_table_1">
						<thead>
							<tr class="f1">
								<th style="width:5%;">选择</th>
								<th style="width:15%;">规则ID</th>
								<th style="width:15%;">规则名称</th>
								<th style="width:25%;">合作伙伴名称</th>
								<th style="width:15%;">方案号</th>
								<th style="width:15%;">定义时间</th>
								<th style="width:10%;">操作</th>
							</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<div id="DefinitionpageDIV" class="page"></div>
				</td>
			</tr>
		</table>
			<div id="channelInfoDiv" style="display:none;width:90%;text-align: center;">
		<div class="table_title_div">
				<table class="table_title" style='width:100%;height: 20px;'>
					<tr>
					<td width="10%"></td>
					<td width="80%" id="interfaceName"></td>
					<td width="10%" align="right"><img src="./images/closedown.gif" alt="关闭"  onclick="closeChannelInfoDiv()"/></td>
					</tr>
				</table>
		</div>
		<table class="table_02" style="width:98%">
			<tr>
				<td>
					<table class="search_table">
						<tr height="30px">
							<td colspan="3" style="text-align:center">
								合作伙伴代码：<input name="txt3"  id="channelCode_choose" class="input_text" />&nbsp;&nbsp;
								合作伙伴名称：<input name="txt3" id="channelName_choose" class="input_text" />&nbsp;&nbsp;
								<input type="button"  class="input_button_1" value="查询" onClick="queryChannelInfo(1)"/>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table id="channelInfoTable"  class="content_table_1">
						<thead>
							<tr class="f1">
			                  <th style="width:5%">选择</th>
			                  <th style="width:10%">合作伙伴代码</th>
			                  <th style="width:20%">合作伙伴名称</th>
			              	</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<div id="channelInfoPageDIV"  class="page"></div>
				</td>
			</tr>
		</table>
		<div align="center">
		   <input type="button" value="确定" onclick="chooseChannelInfo()" class="input_button_3"/>&nbsp;&nbsp;&nbsp;
		   <input type="button" value="取消" onclick="closeChannelInfoDiv()" class="input_button_3"/>
		</div>
	</div>	
		<div id="Loading" style="display:none" align="center">
			<img src="./images/loading.gif" />
		</div>
	<!-- 结束 -->
</body>
</html>